/*
 * OptionPanel.fx
 * Created on 04/03/2009
 */

package changecolor.model;

import javafx.ext.swing.SwingRadioButton;
import javafx.ext.swing.SwingSlider;
import javafx.ext.swing.SwingToggleGroup;
import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;

/**
 * @author José Corcuera
 */

public class OptionPanel extends CustomNode{
    var _root: Node;
    var background: Rectangle;
    var colorOptions: Group;
    var partOptions: Group;
    var sliderHue: SwingSlider;
    var sliderSaturation: SwingSlider;
    var sliderBrightness: SwingSlider;
    var sliderContrast: SwingSlider;
    public var rbAll: SwingRadioButton;
    public var rbCapota: SwingRadioButton;
    public var rbChasis: SwingRadioButton;
    public var rbParachoques: SwingRadioButton;
    var groupRB: SwingToggleGroup;
    public var hue: Number = bind sliderHue.value / 100.0;
    public var saturation: Number = bind sliderSaturation.value / 100.0;
    public var brightness: Number = bind sliderBrightness.value / 100.0;
    public var contrast: Number = bind sliderContrast.value / 100.0;
    public var width: Number;
    public var height: Number;

    init{
        width = 200;
        height = 450;
        background = Rectangle{
            width: width
            height: height
            fill: LinearGradient{
                startX: 0
                startY: -0.2
                endX: 0
                endY: 1.2
                proportional: true
                stops: [
                    Stop{
                        color: Color.BLACK
                        offset: 0.0
                    }
                    Stop{
                        color: Color.WHITE
                        offset: 1.0
                    }
                ]
            }
        }

        colorOptions = Group{
            content: [
                Rectangle{
                    width: 180
                    height: 200
                    arcHeight: 20
                    arcWidth: 20
                    fill: Color.DARKBLUE
                    stroke: Color.WHITE
                    opacity: 0.3
                }
                Rectangle{
                    width: 180
                    height: 40
                    arcHeight: 20
                    arcWidth: 20
                    fill: LinearGradient{
                        startX: 0
                        startY: 0
                        endX: 0
                        endY: 1
                        proportional: true
                        stops: [
                            Stop{
                                color: Color.WHITESMOKE
                                offset: 0.3
                            }
                            Stop{
                                color: Color.TRANSPARENT
                                offset: 0.8
                            }
                        ]
                    }
                }
                Text{
                    translateX: 25
                    translateY: 15
                    fill: Color.DARKBLUE
                    font: Font{
                        name: "Verdana"
                        size: 15
                    }
                    content: "Color Adjustment"
                }

                VBox{
                    translateX: 10
                    translateY: 40
                    spacing: 40
                    content: [
                        Text{
                            content: "Hue:"
                            font: Font{
                                size: 15
                            }
                            fill: Color.WHITE
                        }
                        Text{
                            content: "Saturation:"
                            font: Font{
                                size: 15
                            }
                            fill: Color.WHITE
                        }
                        Text{
                            content: "Brightness:"
                            font: Font{
                                size: 15
                            }
                            fill: Color.WHITE
                        }
                    ]
                }
                VBox{
                    translateX: 10
                    translateY: 50
                    spacing: 40
                    content: [
                        sliderHue = SwingSlider{
                            minimum: -100
                            maximum: 100
                            value: -100
                            width: 160
                        }
                        sliderSaturation = SwingSlider{
                            minimum: 0
                            maximum: 100
                            value: 100
                            width: 160
                        }
                        sliderBrightness = SwingSlider{
                            minimum: 0
                            maximum: 30
                            value: 0
                            width: 160
                        }
                    ]
                }
            ]
        }

        groupRB = SwingToggleGroup{
        };

        partOptions = Group{
            content: [
                Rectangle{
                    width: 180
                    height: 180
                    arcHeight: 20
                    arcWidth: 20
                    fill: Color.DARKRED
                    stroke: Color.WHITE
                    opacity: 0.6
                }
                Rectangle{
                    width: 180
                    height: 40
                    arcHeight: 20
                    arcWidth: 20
                    fill: LinearGradient{
                        startX: 0
                        startY: 0
                        endX: 0
                        endY: 1
                        proportional: true
                        stops: [
                            Stop{
                                color: Color.WHITESMOKE
                                offset: 0.3
                            }
                            Stop{
                                color: Color.TRANSPARENT
                                offset: 0.8
                            }
                        ]
                    }
                }
                Text{
                    translateX: 20
                    translateY: 15
                    fill: Color.DARKRED
                    font: Font{
                        name: "Verdana"
                        size: 15
                    }
                    content: "Choose Car Element"
                }
                HBox{
                    spacing:20
                    content: [
                        VBox{
                    translateX: 10
                    translateY: 45
                    spacing: 20
                    content: [
                        Text{
                            content: "All Elements"
                            font: Font{
                                size: 15
                            }
                            fill: Color.WHITE
                        }
                        Text{
                            content: "Hood"
                            font: Font{
                                size: 15
                            }
                            fill: Color.WHITE
                        }
                        Text{
                            content: "Chassis"
                            font: Font{
                                size: 15
                            }
                            fill: Color.WHITE
                        }
                        Text{
                            content: "Bumper"
                            font: Font{
                                size: 15
                            }
                            fill: Color.WHITE
                        }
                    ]
                }
                VBox{
                    translateX: 10
                    translateY: 30
                    spacing: 14
                    content: [
                        rbAll = SwingRadioButton{
                            toggleGroup: groupRB;
                        }
                        rbCapota = SwingRadioButton{
                            toggleGroup: groupRB;
                        }
                        rbChasis = SwingRadioButton{
                            toggleGroup: groupRB;
                        }
                        rbParachoques = SwingRadioButton{
                            toggleGroup: groupRB;
                        }
                    ]
                }
                    ]
                }                
            ]
        }

        rbAll.selected=true;
        //para el jnlp deshabilito el brightness
       sliderBrightness.enabled=false;
    }

    override function create():Node{
        return
        _root = Group{
            content: [
                background
                VBox{
                    translateX:10
                    translateY:20
                    spacing: 30
                    content: [
                        colorOptions
                        partOptions
                    ]
                }
            ]
        }
    }




}

